<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/percircle.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>


</head>

<body>
    <header class="aui-bar aui-bar-nav">
        <a class="aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">密码安全</div>
    </header>
    <div class="aui-bar-nav-d"></div>

    <ul class="user-data">
        <li class="aui-list-item-arrow" tapmode onclick="user_password()">
            修改登录密码
        </li>
    </ul>
    <ul class="user-data">
        <li class="aui-list-item-arrow" onclick="licai_password()">
            修改交易密码
        </li>
        <li class="aui-list-item-arrow" onclick="forget_password()">
            找回交易密码
        </li>
    </ul>
    <ul class="user-data">
        <li>
            <li>
                手势密码
                <input type="checkbox" class="aui-switch" id='open_gesture' value='0' onclick="open_gesture()">
            </li>
            <li class="aui-list-item-arrow" onclick="licai_password2()">
                找回手势密码
            </li>
    </ul>
    <div class="licai-buy-box-bg" id="bg1">
        <div class="licai-buy-box">
            <h3>修改交易密码</h3>
            <input type="password" name='old_pwd' placeholder="请填写旧密码">
            <input type="password" name='new_pwd' placeholder="请设置新交易密码">
            <input type="password" name='new_pwd2' placeholder="请确认新交易密码">

            <div class="licai-buy-box-btn">
                <a class="green" onclick="change_password()">确定</a>
                <a class="green" onclick="licai_box_close()">取消</a>
            </div>
        </div>
    </div>

    <div class="licai-buy-box-bg" id="bg2">
        <div class="licai-buy-box">
            <h3>请输入登录密码</h3>
            <input type="password" id='login_pwd' placeholder="请输入登录密码">

            <div class="licai-buy-box-btn">
                <a class="green" onclick="change_shoushi_password()">确定</a>
                <a class="green" onclick="licai_box_close2()">取消</a>
            </div>
        </div>
    </div>

</body>
<script type="text/javascript">
    apiready = function() {
        lastCaptcha = '';
        // setMobile();
        var temp = $api.getStorage('open_gesture');
        if (temp == 'true') {
            $("#open_gesture").prop("checked", true);
        } else {
            $("#open_gesture").prop("checked", false);
        }

    }

    function open_gesture() {
        var open_gesture = $("#open_gesture").prop("checked");
        $api.setStorage('open_gesture', open_gesture);

    }

    function forget_password() {
        // api.openWin({
        //     name: 'forget_mobile_verification',
        //     url: './forget_mobile_verification.html',
        // });
        api.openWin({
            name: 'forget_deal_password',
            url: './forget_deal_password.html',
        });

    }


    function change_password() {
        var userid = $api.getStorage('userid');
        var old_pwd = $(" input[ name='old_pwd' ] ").val();
        var new_pwd = $(" input[ name='new_pwd' ] ").val();
        var new_pwd2 = $(" input[ name='new_pwd2' ] ").val();


        api.ajax({
            url: webAddress + '/index.php?ctl=app_user_center2&act=edit_paypassword',
            method: 'post',
            data: {
                values: {
                    id: userid,
                    old_pwd: old_pwd,
                    new_pwd: new_pwd,
                    new_pwd2: new_pwd2,
                },
            }
        }, function(ret, err) {
            if (ret.status == 1) {
                $api.setStorage('payPassWord', new_pwd);
                api.toast({
                    msg: ret.info,
                    duration: 2000,
                    location: 'bottom'
                });
                setTimeout("api.closeWin()", 500);

            } else {
                api.toast({
                    msg: ret.info,
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });

    }

    function change_shoushi_password() {

        var deviceId = api.deviceId;
        var mobile = $api.getStorage('mobile');
        var mobileValue = mobile.value;
        var PWD = $api.byId('login_pwd');
        var PWDValue = PWD.value;

        api.ajax({
            url: webAddress + "/index.php?ctl=app_user_center&act=mobiledologin&ajax=1",
            method: 'post',
            data: {
                values: {
                    mobile: mobileValue,
                    user_pwd: PWDValue,
                    apns_code: deviceId
                },
            }
        }, function(ret, err) {
            if (ret.status == 0) {
                api.toast({
                    msg: '登陆密码错误',
                    duration: 2000,
                    location: 'bottom'
                });
                $("#login_pwd").val('');
                PWD.focus();
                return false;
            } else {
                // alert(JSON.stringify(err));
                $("#login_pwd").val('');
                $("#bg2").hide();
                licai_box();
            }
        });
    }

    function licai_password() {
        // $(".licai-buy-box-bg").show();
        $("#bg1").show();
    }


    function licai_box_close() {
        // $(".licai-buy-box-bg").hide();
        $("#bg1").hide();
    }

    function licai_password2() {
        // $(".licai-buy-box-bg-2").show();
        $("#bg2").show();
    }

    function licai_box_close2() {
        // $(".licai-buy-box-bg-2").hide();
        $("#bg2").hide();
    }

    function licai_box() {
        api.openWin({
            name: 'h5Lock',
            url: './h5Lock.html',
            pageParam: {
                name: 'user_safe'
            }
        });

    }

    function lock() {
        $api.setStorage('is_gesture', true);
    }









    function user_password() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }
        api.openWin({
            name: 'user_password',
            url: './user_password.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    };


    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
